Skip to content

refactor(sui-indexer): rename redeem Solved status to Signing#332

Merged
vuvoth merged 9 commits intomasterfrom
feat/merge-solve-with-signing-state
Feb 4, 2026
Merged

refactor(sui-indexer): rename redeem Solved status to Signing#332
vuvoth merged 9 commits intomasterfrom
feat/merge-solve-with-signing-state

Conversation

@vuvoth
Copy link
Contributor

@vuvoth vuvoth commented Feb 3, 2026

Description

Closes: #266


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • added appropriate labels to the PR
  • provided a link to the relevant issue or specification
  • added a changelog entry to CHANGELOG.md
  • included doc comments for public functions
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary

Summary by Sourcery

Align redeem request lifecycle to use a new Signing status and associated processing flow instead of Solved.

Enhancements:

  • Rename the redeem request status from Solved to Signing across the indexer models, storage layer, and event handling.
  • Update redeem processing to fetch and handle redeems in Signing state and adjust logging/messages to reflect the new status transition.
  • Adapt the redeem event handler to mark redeems as Signing when a SolvedEvent is received and update the redeem solver pipeline accordingly.

Tests:

  • Update storage tests to cover the new Signing status and the renamed storage methods for marking and retrieving signing redeems.

Signed-off-by: Vu Vo <vu.voth@gmail.com>
@vuvoth vuvoth requested a review from a team as a code owner February 3, 2026 11:10
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Feb 3, 2026

Reviewer's Guide

This PR aligns the redeem lifecycle with a new "signing" status by renaming the previous "solved" status across the indexer service, storage layer, handler, scheduler, and tests, and updating the processing flow to operate on redeems in the signing state.

Sequence diagram for the redeem signing flow

sequenceDiagram
    actor Cron
    participant Indexer as runRedeemSolver
    participant Service as RedeemService
    participant Storage as D1Storage
    participant Handler as SuiEventHandler

    Cron->>Indexer: Trigger redeem solver
    Indexer->>Service: processPendingRedeems()
    Indexer->>Service: solveReadyRedeems()
    Service-->>Indexer: solved redeems ready
    Indexer->>Service: processSigningRedeems()
    Service->>Storage: getSigningRedeems()
    Storage-->>Service: RedeemRequestWithInputs[]
    loop for each signing redeem
        Service->>Service: processSolvedRedeem(req)
        Service->>Service: makeSigning(req)
        Service->>Storage: markRedeemSigning(redeemId)
    end

    Handler->>Handler: handleSolvedRedeem(SolvedEventRaw)
    Handler->>Storage: upsertRedeemInputs(redeemId, utxoIds, dwalletIds)
    Handler->>Storage: markRedeemSigning(redeemId)
    Storage-->>Handler: status updated to Signing
Loading

Class diagram for updated redeem signing lifecycle

classDiagram
    class RedeemStatusEnum {
        <<enumeration>>
        Pending
        Proposed
        Signing
        Signed
    }

    class D1Storage {
        +markRedeemProposed(redeemId number, utxoIds number[], lockTimeMs number) Promise~void~
        +markRedeemSigning(redeemId number) Promise~void~
        +getSigningRedeems() Promise~RedeemRequestWithInputs[]~
        +upsertRedeemInputs(redeemId number, utxoIds number[], dwalletIds string[]) Promise~void~
    }

    class RedeemService {
        +processPendingRedeems() Promise~void~
        +solveReadyRedeems() Promise~void~
        +processSigningRedeems() Promise~void~
        +broadcastReadyRedeems() Promise~void~
        -processSolvedRedeem(req RedeemRequestWithInputs) Promise~void~
        -makeSigning(req RedeemRequestWithInputs) Promise~void~
        -storage D1Storage
    }

    class SuiEventHandler {
        +handle(event any) Promise~void~
        -handleSolvedRedeem(e SolvedEventRaw) Promise~void~
        -storage D1Storage
    }

    RedeemService --> D1Storage : uses
    SuiEventHandler --> D1Storage : uses
    D1Storage --> RedeemStatusEnum : sets_status
Loading

Flow diagram for updated runRedeemSolver pipeline with signing status

flowchart TD
    A[runRedeemSolver] --> B[processPendingRedeems]
    A --> C[solveReadyRedeems]
    C --> D[processSigningRedeems]
    D --> E[getSigningRedeems from D1Storage]
    D --> F[processSolvedRedeem and makeSigning]
    F --> G[markRedeemSigning in D1Storage]
    A --> H[broadcastReadyRedeems]
Loading

File-Level Changes

Change Details Files
Rename redeem status from "Solved" to "Signing" across the model and storage APIs, and adjust related logging.
  • Update RedeemStatusEnum to replace the Solved status with Signing.
  • Rename storage methods from markRedeemSolved/getSolvedRedeems to markRedeemSigning/getSigningRedeems and switch their implementation to use the Signing status.
  • Adjust error/log messages and method identifiers to reflect the new signing terminology.
packages/sui-indexer/src/models.ts
packages/sui-indexer/src/storage.ts
Update redeem event handling and background processing to work with the new signing status and method names.
  • Rename processSolvedRedeems to processSigningRedeems and change it to pull redeems via getSigningRedeems.
  • Update event handler for SolvedEvent to call handleSolvedRedeem, which now marks redeems as Signing instead of Solved.
  • Wire the new processSigningRedeems into the redeem solver execution pipeline and its error reporting labels.
packages/sui-indexer/src/redeem-service.ts
packages/sui-indexer/src/handler.ts
packages/sui-indexer/src/index.ts
Adjust tests to assert the new signing status and the renamed storage methods.
  • Rename tests for markRedeemSolved/getSolvedRedeems to markRedeemSigning/getSigningRedeems.
  • Update expectations to assert RedeemRequestStatus.Signing instead of RedeemRequestStatus.Solved after status transitions.
  • Ensure test setup uses markRedeemSigning where previously markRedeemSolved was used.
packages/sui-indexer/src/storage.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@vuvoth vuvoth marked this pull request as draft February 3, 2026 11:10
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • There are several spelling inconsistencies for the new status (e.g., markRedeemSinging, sinnings) that should be corrected to Signing to keep method/variable names consistent and avoid confusion.
  • The log context in makeSigning (formerly solveRequest) still references the old naming pattern; double-check log msg and method fields throughout to keep terminology aligned with the new Signing status.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- There are several spelling inconsistencies for the new status (e.g., `markRedeemSinging`, `sinnings`) that should be corrected to `Signing` to keep method/variable names consistent and avoid confusion.
- The log context in `makeSigning` (formerly `solveRequest`) still references the old naming pattern; double-check log `msg` and `method` fields throughout to keep terminology aligned with the new `Signing` status.

## Individual Comments

### Comment 1
<location> `packages/sui-indexer/src/storage.ts:333-337` </location>
<code_context>
 	}

-	async markRedeemSolved(redeemId: number): Promise<void> {
+	async markRedeemSinging(redeemId: number): Promise<void> {
 		try {
 			await this.db
 				.prepare("UPDATE nbtc_redeem_requests SET status = ? WHERE redeem_id = ?")
-				.bind(RedeemRequestStatus.Solved, redeemId)
+				.bind(RedeemRequestStatus.Signing, redeemId)
 				.run();
 		} catch (error) {
</code_context>

<issue_to_address>
**issue (typo):** The method name `markRedeemSinging` appears to be a typo and should probably be `markRedeemSigning`.

This looks like an accidental misspelling given that the status and related code use `Signing`. Please rename the method to `markRedeemSigning` and update all its call sites for consistency and clarity.

Suggested implementation:

```typescript
	async markRedeemSigning(redeemId: number): Promise<void> {

```

1. Search the entire codebase for `markRedeemSinging` and rename all call sites to `markRedeemSigning`.
2. If this method is part of a public interface (e.g., exported class), ensure any tests, mocks, or type declarations referencing `markRedeemSinging` are also updated accordingly.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Signed-off-by: Vu Vo <vu.voth@gmail.com>
Signed-off-by: Vu Vo <vu.voth@gmail.com>
@vuvoth vuvoth marked this pull request as ready for review February 4, 2026 08:45
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

  • In RedeemService.processSigningRedeems, the local variable is named sinnings instead of signings, which makes the code harder to read; consider renaming it to signings (or similar) for clarity.
  • Now that the status is Signing, consider renaming processSolvedRedeem and the related log messages that still say "solved" to use "signing" terminology so the method names and logs consistently reflect the new lifecycle state.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `RedeemService.processSigningRedeems`, the local variable is named `sinnings` instead of `signings`, which makes the code harder to read; consider renaming it to `signings` (or similar) for clarity.
- Now that the status is `Signing`, consider renaming `processSolvedRedeem` and the related log messages that still say "solved" to use "signing" terminology so the method names and logs consistently reflect the new lifecycle state.

## Individual Comments

### Comment 1
<location> `packages/sui-indexer/src/redeem-service.ts:55-56` </location>
<code_context>
-	async processSolvedRedeems() {
+	async processSigningRedeems() {
 		// NOTE: here we are processing only 50 redeems every minute (every cron), we are not
 		// looping thought all the solved redeems to avoid cloudflare timeout, since we are
 		// already waiting for ika to sign, when calling ikaSdk.getPresignInParicularState
-		const solved = await this.storage.getSolvedRedeems();
</code_context>

<issue_to_address>
**nitpick (typo):** Update the comment to reflect the new `signing` status and fix the minor typo.

This still mentions "solved redeems" even though the function now handles `signing` redeems. Please update the phrase to "signing redeems" and correct the typo "thought" → "through" to match the new flow and fix the wording.

```suggestion
		// NOTE: here we are processing only 50 redeems every minute (every cron), we are not
		// looping through all the signing redeems to avoid cloudflare timeout, since we are
```
</issue_to_address>

### Comment 2
<location> `packages/sui-indexer/src/handler.ts:93-94` </location>
<code_context>
-		await this.storage.markRedeemSolved(Number(e.redeem_id));
+		await this.storage.markRedeemSigning(Number(e.redeem_id));

 		logger.info({
 			msg: "Marked redeem as solved and added inputs",
</code_context>

<issue_to_address>
**suggestion:** Log message still says "solved" although the status is now set to `Signing`.

Since this handler now calls `markRedeemSigning`, please update the log text to say `signing` instead of `solved` to keep status transitions clear in the logs.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Signed-off-by: Vu Vo <vu.voth@gmail.com>
Signed-off-by: Vu Vo <vu.voth@gmail.com>
Signed-off-by: Vu Vo <vu.voth@gmail.com>
@vuvoth
Copy link
Contributor Author

vuvoth commented Feb 4, 2026

@sourcery-ai title

@sourcery-ai sourcery-ai bot changed the title feat: remove handleSolved process refactor(sui-indexer): rename redeem Solved status to Signing Feb 4, 2026
Signed-off-by: Vu Vo <vu.voth@gmail.com>
Copy link
Contributor

@sczembor sczembor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pre-approve

Co-authored-by: sczembor <43810037+sczembor@users.noreply.github.com>
Signed-off-by: vuvoth <vu.voth@gmail.com>
@vuvoth vuvoth merged commit 85f2cf6 into master Feb 4, 2026
12 checks passed
@vuvoth vuvoth deleted the feat/merge-solve-with-signing-state branch February 4, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nBTC Redeem: merge solved stage with signing stage

2 participants